<!DOCTYPE html>
<html>

	<head>
		<!-- 声明文档使用的字符编码 -->
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<!-- 为移动设备添加 viewport -->
		<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
		<!-- 针对手持设备优化，主要是针对一些老的不识别viewport的浏览器，比如黑莓 -->
		<meta name="HandheldFriendly" content="true">
		<!-- 优先使用 IE 最新版本和 Chrome -->
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

		<title>黑图视界</title>
		<meta name="keywords" content="黑图视界">
		<meta name="description" content="黑图视界">
		<script type="text/javascript" src="../js/setFontSize.js"></script>
		<link rel="stylesheet" href="../css/swiper.min.css" />
		<link rel="stylesheet" href="../css/main.css" />
	</head>

	<body>
		<div id="app">
			<main>
				<section class="homeDY">
					<div class="container">
						<div class="userName whiteBg mbt30 radius20 clearfix">
							<div class="txBox">
								<img src="../img/tx.png" class="objectCover"/>
							</div>
							<div class="name">欢迎您！{{loginManager.managername}}
							<button @click="signOut">退出登录</button>
							</div>
						</div>
						<ul class="list">
							<li class="listItem bg1" @click="selectFile">
								<a >
									<div class="name">扫码核销</div>
									<div class="en">Sweep the code verification</div>
								</a>
									<input id="fileBox" type="file" name="uploadFile" style="display: none" @change="submitQr">
							</li>
							<li class="listItem bg2">
								<a href="/managerclient/hexiaoma.html">
									<div class="name">核销码核销</div>
									<div class="en">Cancel after verification code</div>
								</a>
							</li>
							<li class="listItem bg3">
								<a href="/managerclient/record.html">
									<div class="name">优惠券核销记录</div>
									<div class="en">Coupon verification record</div>
								</a>
							</li>
							<li class="listItem bg1">
								<a href="/managerclient/myGymList.html">
									<div class="name">我的场馆</div>
									<div class="en">Check and edit my Gym</div>
								</a>
							</li>
							<li class="listItem bg1">
								<a href="/managerclient/myActivityList.html">
									<div class="name">我的活动</div>
									<div class="en">Check and edit my Activity</div>
								</a>
							</li>
						</ul>
					</div>
				</section>
			</main>
		</div>

		<script type="text/javascript" src="../js/jquery-3.3.1.min.js"></script>
		<script type="text/javascript" src="../js/swiper.min.js"></script>
		<script type="text/javascript" src="../js/layer/layer.js" ></script>
		<script type="text/javascript" src="../js/main.js"></script>
		<script src="../js/vue.js"></script>
		<script src="../js/axios.js"></script>
	</body>
<script>

const app = new Vue({
	el:"#app",
	data:{
		loginManager:{},
	},
	methods:{
		selectFile(){
			$("#fileBox").click();
		},
		submitQr(){

			let file = document.getElementById("fileBox").files[0];
			let formData = new FormData();
			formData.append("uploadFile",file,file.name)
			const config = {
				headers: { "Content-Type": "multipart/form-data;boundary="+new Date().getTime() }
			};
			axios.post("/qrcode/scan",formData,config).then(function (res) {
				if (res.data==="noJpg") layer.msg("请上传jpg或png图片")
				else if (res.data==="noQr") layer.msg("扫描失败")
				else if (res.data==="noSearch") layer.msg("查不到该票信息")
				else if (res.data==="scanDown") layer.msg("该票已被核销")
				else if (res.data==="noLogin") location.href="/managerclient/login.html"
				else if (res.data==="success") layer.msg("核销成功")
			})
		},
		signOut(){
			axios.get("/manage/signOut").then(function (res) {
				location.href = "/managerclient/login.html"
			})
		}
	},
	created(){
		axios.get("/manage/chackLogin").then(function (res) {
			if (JSON.stringify(res.data)==='""') location.href="/managerclient/login.html";
			else app.loginManager = res.data;
		})
	}
})
</script>

</html>